#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <map>
#include <climits>

using namespace std;
const int N=105;
int dp[N][N];
int v[]={100,200,200,220};
int main(){
    memset(dp,0,sizeof(dp));
    string s;
    cin >> s;
    int len=s.size();
    for(int i=len-2;i>=0;i--){
        for(int j=i+1;j<len;j++){
            if(s[i]==s[j]){
                dp[i][j]=dp[i+1][j-1];
            }else{
                dp[i][j]=min(dp[i+1][j]+v[(s[i]-'1')],dp[i][j-1]+v[(s[j]-'1')]);
            }
        }
    }
    cout << dp[0][len-1]<<endl;

    return 0;
}